package net.qiqbframework.common.utils;

import java.util.Objects;


public abstract class StringUtils {

    private static final String EMPTY_STRING = "";

    private StringUtils() {
        // Utility class
    }

    /**
     * Validate whether the given {@link String} {@code s} is not {@code null} and not empty (where empty is defined as
     * {@code ""}).
     *
     * @param s the {@link String} to validate whether it is not {@code null} and not empty
     * @return {@code true} if the given {@link String} {@code s} is not {@code null} and not empty, {@code false}
     * otherwise
     */
    public static boolean nonEmptyOrNull(Object s) {
        return Objects.nonNull(s) && !EMPTY_STRING.equals(s);
    }

    /**
     * Validate whether the given {@link String} {@code s} is {@code null} or not empty (where empty is defined as
     * {@code ""}).
     *
     * @param s The {@link String} to validate whether it is {@code null} or empty.
     * @return {@code true} if the given {@link String} {@code s} is not {@code null} and not empty, {@code false}
     * otherwise.
     */
    public static boolean isEmptyOrNull(Object s) {
        return Objects.isNull(s) || EMPTY_STRING.equals(s);
    }

    /**
     * Validate whether the given {@link String} {@code s} not empty (where empty is defined as
     * {@code ""}).
     *
     * @param s the {@link String} to validate whether not empty
     * @return {@code true} if the given {@link String} {@code s} is not empty, {@code false}
     * otherwise
     */
    public static boolean nonEmpty(Object s) {
        return !EMPTY_STRING.equals(s);
    }

    /**
     * Return the given {@code s}, with its first character lowercase.
     *
     * @param s The input string to adjust to a version with the first character as a lowercase.
     * @return The input string, with first character lowercase.
     */
    public static String lowerCaseFirstCharacterOf(String s) {
        return s.substring(0, 1).toLowerCase() + s.substring(1);
    }
}

